package com.yanqu.road.server.cmd.activity.washe.cross;

import com.yanqu.road.entity.enums.washe.eWasheHonorMomentType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.WasheProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.washe.WasheModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.HashMap;
import java.util.Map;

@Cmd(code = GameProtocol.S_WASHE_SEND_EXPRESSION_FROM_CROSS, desc = "")
public class WasheSendExpressionFromCrossCmd extends AbstractCommand {

    private WasheProto.WasheOperateRespMsg respMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        respMsg = WasheProto.WasheOperateRespMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if (respMsg.getRet() == 0) {
            Map<Integer, Long> typeValueMap = new HashMap<>();
            typeValueMap.put(eWasheHonorMomentType.SendExpressionTimes.getIntValue(), 1L);
            player.getModule(WasheModule.class).changeHistory(typeValueMap);
        }
    }

    @Override
    public void sendData(GamePlayer player) {
        player.sendPacket(ClientProtocol.U_WASHE_OPERATE, respMsg.toBuilder());
    }
}
